package br.com.ruidobrasil.util.componentes.slides {
	
	import flash.events.MouseEvent;
	
	import mx.containers.HBox;
	import mx.events.FlexEvent;
	
	public class BotaoSlide extends HBox {
		
		public var numeroBotao: int;
		
		public function BotaoSlide() {
			super();
			this.addEventListener(FlexEvent.CREATION_COMPLETE, init);
		}
		
		private function init(event: FlexEvent): void {
			this.width = 15;
			this.height = 15;
			this.buttonMode = true;
			this.setStyle("backgroundColor", numeroBotao % 2 == 1 ? "#9ac72c" : "#01629b");
			this.setStyle("backgroundAlpha", "0.5");
			
			this.addEventListener(MouseEvent.MOUSE_OVER, mouseOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
			this.addEventListener(MouseEvent.CLICK, click);
		}
		
		private function mouseOver(event: MouseEvent): void {
			this.setStyle("backgroundAlpha", 1);
		}
		
		private function mouseOut(event: MouseEvent): void {
			this.setStyle("backgroundAlpha", 0.5);
		}
		
		private function click(event: MouseEvent): void {
			var botaoSlideEvent: BotaoSlideEvent = new BotaoSlideEvent(BotaoSlideEvent.BOTAO_SLIDE_EVENT, numeroBotao);
			dispatchEvent(botaoSlideEvent);
		}
	}
}